﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data.SqlClient;
using System.Data ;

/// <summary>
/// users 的摘要说明
/// </summary>
public class users  : SQLHelper
{
 
    private string _id;
    private string _ps;
    private string _name;
    private string _phone;
    private string _ren;
    private string _address;
    private string _dh;
    private string _time;
    private string _guige;
    private string _place;
    private string _type;
    private string _number;
    private string _price;
    private string _ze;
    private string _gid;
    private string _tname;
    private string _fun;
    private string _birth;
    private string _gname;
    private string _youxiaoqi;
    private string _numb;
    public string id
    {
        get { return _id; }
        set { _id = value; }
    }
    public string numb
    {
        get { return _numb; }
        set { _numb = value; }
    }

    public string ps
    {
        get { return _ps; }
        set { _ps = value; }
    }
    public string name
    {
        get { return _name; }
        set { _name = value; }
    }


    public string ren
    {
        get { return _ren; }
        set { _ren = value; }
    }
    
    public string phone
    {
        get { return _phone; }
        set { _phone = value; }
    }
   
    public string address
    {
        get { return _address; }
        set { _address = value; }
    }

    public string dh
    {
        get { return _dh; }
        set { _dh = value; }
    }
    public string time
    {
        get { return _time; }
        set { _time = value; }
    }
    public string guige
    {
        get { return _guige; }
        set { _guige = value; }
    }

    public string type
    {
        get { return _type; }
        set { _type = value; }
    }
    public string fun
    {
        get { return _fun; }
        set { _fun = value; }
    }
    public string price
    {
        get { return _price; }
        set { _price = value; }
    }
    public string place
    {
        get { return _place ; }
        set { _place = value; }
    }
    public string ze
    {
        get { return _ze; }
        set { _ze = value; }
    }
    public string number
    {
        get { return _number; }
        set { _number = value; }
    }
    public string youxiaoqi
    {
        get { return _youxiaoqi; }
        set { _youxiaoqi = value; }
    }
    public string gname
    {
        get { return _gname; }
        set { _gname = value; }
    }
   
    public string gid
    {
        get { return _gid; }
        set { _gid = value; }
    }

    public string tname
    {
        get { return _tname; }
        set { _tname = value; }
    }

    public string birth
    {
        get { return _birth; }
        set { _birth = value; }
    }
	public users()
	{
		//
		// TODO: 在此处添加构造函数逻辑
		//

	}
    public DataSet getkque(users tmp)  //获取过期商品
    {
        string sql = "select * from K_TABLE where K_NUMBER = '0'";
        DataSet ds = tmp.GetDs(sql);
        return ds;
    }
   
    //登录
    public int login(users tmp)
    {
        string sql = "select count(*) from T_TABLE where T_NAME='" + tmp.name + "'" +
          " and T_PW='" + tmp.ps + "'";
        int result = 0;
        result = tmp.ExeScale(sql);
        return result;
    }
    public int loginn(users tmp)
    {
        string sql = "select count(*) from H_TABLE where H_NAME='" + tmp.name + "'" +
          " and H_PW='" + tmp.ps + "'";
        int result = 0;
        result = tmp.ExeScale(sql);
        return result;
    }
    public int addjinhuo(users tmp)
    {
        string sql = "insert into J_TABLE(J_DANHAO,J_TIME,J_ID,J_NAME,J_NUMBER,J_PRICE,J_YOUQI,J_ZE,J_GID,J_TNAME)  values('" + tmp.dh + "','" + tmp.time + "','" + tmp.id + "','" + tmp.name + "','" + tmp.number + "','" + tmp.price + "','" + tmp.youxiaoqi + "','" + tmp.ze + "','" + tmp.gid + "','" + tmp.tname + "')";
        int result = 0;
        result = tmp.ExeNnQuery(sql);
        return result;
    }
    public int addxiaoshou(users tmp)
    {
        string sql = "insert into X_TABLE(X_DANHAO,X_TIME,X_ID,X_NAME,X_NUMBER,X_PRICE,X_ZE,X_TNAME)  values('" + tmp.dh + "','" + tmp.time + "','" + tmp.id + "','" + tmp.name + "','" + tmp.number + "','" + tmp.price + "','" + tmp.ze + "','" + tmp.tname + "')";
        int result = 0;
        result = tmp.ExeNnQuery(sql);
        return result;
    }
    public int addyaopin(users tmp)
    {
        string sql = "insert into Y_TABLE(Y_ID,Y_NAME,Y_GUIGE,Y_TYPE,Y_FUNCTION,Y_PLACE,Y_GNAME)  values('" + tmp.id + "','" + tmp.name + "','" + tmp.guige + "','" + tmp.type + "','" + tmp.place + "','" + tmp.fun + "','" + tmp.gname+ "')";
        int result = 0;
        result = tmp.ExeNnQuery(sql);
        return result;
    }
    public int addgong(users tmp)
    {
        string sql = "insert into G_TABLE(G_ID,G_NAME,G_REN,G_PHONE,G_ADDRESS)  values('" + tmp.id + "','" + tmp.name + "','" + tmp.ren + "','" + tmp.phone + "','" + tmp.address + "')";
        int result = 0;
        result = tmp.ExeNnQuery(sql);
        return result;
    }
    public int addhu(users tmp)
    {
        string sql = "insert into H_TABLE(H_ID,H_NAME,H_PW,H_PHONE,H_ADDRESS,H_BIRTHDAY)  values('" + tmp.id + "','" + tmp.name + "','" + tmp.ps + "','" + tmp.phone + "','" + tmp.address + "','"+ tmp .birth+"')";
        int result = 0;
        result = tmp.ExeNnQuery(sql);
        return result;
    }
    public int adduser(users tmp)
    {
        string sql = "insert into T_TABLE(T_ID,T_NAME,T_PW,T_PHONE,T_ADDRESS,T_BIRTHDAY)  values('" + tmp.id + "','" + tmp.name + "','" + tmp.ps + "','" + tmp.phone + "','" + tmp.address + "','" + tmp.birth + "')";
        int result = 0;
        result = tmp.ExeNnQuery(sql);
        return result;
    }
    public int addkucun(users tmp)
    {
        string sql = "insert into K_TABLE(K_ID,K_NAME,K_DANHAO,K_TNAME,K_TIME,K_NUMBER)  values('" + tmp.id + "','" + tmp.name + "','" + tmp.dh + "','" + tmp.time + "','" + tmp.tname + "','" + tmp.number + "')";
        int result = 0;
        result = tmp.ExeNnQuery(sql);
        return result;
    }
    public DataSet GetAlljinhuo(users us)
    {

        string sql = "select * from J_TABLE";
        DataSet ds = us.GetDs(sql);
        return ds;
    }
    public DataSet GetAllhu(users us)
    {

        string sql = "select * from H_TABLE";
        DataSet ds = us.GetDs(sql);
        return ds;
    }
    public int GetAllhuu(users us)
    {

        string sql = "select * from H_TABLE";
        int ds = us.ExecuteScalar(sql);
        return ds;
    }
    public DataSet GetAlluser(users us)
    {

        string sql = "select * from T_TABLE";
        DataSet ds = us.GetDs(sql);
        return ds;
    }
    public DataSet GetAllgong(users us)
    {

        string sql = "select * from G_TABLE";
        DataSet ds = us.GetDs(sql);
        return ds;
    }
    public DataSet GetAllxiaoshou(users us)
    {

        string sql = "select * from X_TABLE";
        DataSet ds = us.GetDs(sql);
        return ds;
    }
    public DataSet GetAllyaopin(users us)
    {

        string sql = "select * from Y_TABLE";
        DataSet ds = us.GetDs(sql);
        return ds;
    }

    public DataSet GetAllkucun(users us)
    {

        string sql = "select * from K_TABLE";
        DataSet ds = us.GetDs(sql);
        return ds;
    }
    public int Delete(users tmp)
    {
        string sql = "delete from J_TABLE where J_DANHAO='" + tmp.dh + "'";
        int result = tmp.ExeNnQuery(sql);
        return result;
    }
    public int Deletegong(users tmp)
    {
        string sql = "delete from G_TABLE where G_ID='" + tmp.id + "'";
        int result = tmp.ExeNnQuery(sql);
        return result;
    }
    public int Deletehu(users tmp)
    {
        string sql = "delete from H_TABLE where H_ID='" + tmp.id + "'";
        int result = tmp.ExeNnQuery(sql);
        return result;
    }
    public int Deleteuser(users tmp)
    {
        string sql = "delete from T_TABLE where T_ID='" + tmp.id + "'";
        int result = tmp.ExeNnQuery(sql);
        return result;
    }
    public int Deletekucun(users tmp)
    {
        string sql = "delete from K_TABLE where K_ID='" + tmp.id + "'";
        int result = tmp.ExeNnQuery(sql);
        return result;
    }
    public int Deletexiaoshou(users tmp)
    {
        string sql = "delete from X_TABLE where X_ID='" + tmp.id + "'";
        int result = tmp.ExeNnQuery(sql);
        return result;
    }
    public int Deleteyaopin(users tmp)
    {
        string sql = "delete from Y_TABLE where Y_ID='" + tmp.id + "'";
        int result = tmp.ExeNnQuery(sql);
        return result;
    }
    public int  Updajinhuo(users us)
    {
        string sql = "update J_TABLE set J_DANHAO='" + us.dh + "',J_TIME='" + us.time + "',J_ID='" + us.id + "',J_NAME='" + us.name + "',J_NUMBER='" + us.number + "',J_PRICE='" + us.price + "',J_YOUQI='" + us.youxiaoqi + "',J_GID='" + us.gid + "',J_TNAME='" + us.tname + "',J_ZE='" + us.ze + "'where J_DANHAO='" + us.dh + "'";
        int  result = us.ExeNnQuery(sql);
        return result;
    }
    public int Updaxiaoshou(users us)
    {
        string sql = "update X_TABLE set X_DANHAO='" + us.dh + "',X_TIME='" + us.time + "',X_ID='" + us.id + "',X_NAME='" + us.name + "',X_NUMBER='" + us.number + "',X_PRICE='" + us.price + "',X_TNAME='" + us.tname + "',X_ZE='" + us.ze + "'where X_ID='" + us.id + "'";
        int result = us.ExeNnQuery(sql);
        return result;
    }
    public int Updayaopin(users us)
    {
        string sql = "update Y_TABLE set Y_ID='" + us.id + "',Y_NAME='" + us.name + "',Y_GUIGE='" + us.guige + "',Y_PLACE='" + us.place + "',Y_FUNCTION='" + us.fun + "',Y_TYPE='" + us.type + "',Y_GNAME='" + us.gname + "'where Y_ID='" + us.id + "'";
        int result = us.ExeNnQuery(sql);
        return result;
    }
    public int Updagong(users us)
    {
        string sql = "update G_TABLE set G_ID='" + us.id + "',G_NAME='" + us.name + "',G_REN='" + us.ren + "',G_PHONE='" + us.phone + "',G_ADDRESS='" + us.address + "'where G_ID='" + us.id + "'";
        int result = us.ExeNnQuery(sql);
        return result;
    }
    public int Updahu(users us)
    {
        string sql = "update H_TABLE set H_ID='" + us.id + "',H_NAME='" + us.name + "',H_PW='" + us.ps + "',H_PHONE='" + us.phone + "',H_ADDRESS='" + us.address + "',H_BIRTHDAY='"+ us .birth +"'where H_ID='" + us.id + "'";
        int result = us.ExeNnQuery(sql);
        return result;
    }
    public int Updauser(users us)
    {
        string sql = "update T_TABLE set T_ID='" + us.id + "',T_NAME='" + us.name + "',T_PW='" + us.ps + "',T_PHONE='" + us.phone + "',T_ADDRESS='" + us.address + "',T_BIRTHDAY='" + us.birth + "' where T_ID='" + us.id + "'";
        int result = us.ExeNnQuery(sql);
        return result;
    }
    public int Updakucun(users us)
    {
        string sql = "update K_TABLE set K_ID='" + us.id + "',K_NAME='" + us.name + "',K_DANHAO='" + us.dh + "',K_TIME='" + us.time + "',K_TNAME='" + us.tname + "',K_NUMBER='" + us.number + "'where K_ID='" + us.id + "'";
        int result = us.ExeNnQuery(sql);
        return result;
    }
    public int  Updakc(users us)
    {
        string sql = "update K_TABLE set K_NUMBER='"+us.numb +"'where K_ID='"+us.id +"'";
        int sum=us.ExeNnQuery(sql);
        return sum;
    }
  
    public DataSet Getonejinhuo(users us)
    {

        string sql = "select * from J_TABLE  where J_DANHAO='" + us.dh + "'";
        DataSet ds = us.GetDs(sql);
        return ds;
    }
    public DataSet Getonexiaoshou(users us)
    {

        string sql = "select * from X_TABLE where X_ID='" + us.id + "'";
        DataSet ds = us.GetDs(sql);
        return ds;
    }
    public DataSet Getonekucun(users us)
    {

        string sql = "select * from K_TABLE where K_ID='" + us.id + "'";
        DataSet ds = us.GetDs(sql);
        return ds;
    }
    public DataSet Getonegong(users us)
    {

        string sql = "select * from G_TABLE where G_ID='" + us.id + "'";
        DataSet ds = us.GetDs(sql);
        return ds;
    }
    public DataSet Getonehu(users us)
    {

        string sql = "select * from H_TABLE where  H_NAME='"+ us.name +"'";
        DataSet ds = us.GetDs(sql);
        return ds;
    }
    public DataSet Getoneuser(users us)
    {

        string sql = "select * from T_TABLE where T_ID='" + us.id + "' or T_NAME='" + us.name + "'";
        
        DataSet ds = us.GetDs(sql);
        return ds;
    }
    public DataSet Getoneyaopin(users us)
    {

        string sql = "select * from Y_TABLE where Y_ID='" + us.id + "'" ;
        DataSet ds = us.GetDs(sql);
        return ds;
    }
    public SqlDataReader getallhu(users tmp)  //查询全部信息
    {
        string sql = "Select H_ID,H_NAME,H_PW,H_ADDRESS,H_PHONE,H_BIRTHDAY from H_TABLE where H_ID = '" + tmp.id + "'";
        SqlDataReader rd = tmp.ExecuteReader(sql);
        return rd;
    }
    public SqlDataReader getallhuu(users tmp)  //查询全部信息
    {
        string sql = "Select H_NAME from H_TABLE where H_NAME = '" + tmp.name + "'";
        SqlDataReader rd = tmp.ExecuteReader(sql);
        return rd;
    }
    public int chahu(users tmp) //验证商品名
    {
        string sql = "select count(*) from H_TABLE where H_ID = '" + tmp.id + "'";
        int result = tmp.ExecuteScalar(sql);
        return result;
    }
    public SqlDataReader getalluser(users tmp)  //查询全部信息
    {
        string sql = "Select T_ID,T_NAME,T_PW,T_ADDRESS,T_PHONE,T_BIRTHDAY from T_TABLE where T_ID = '" + tmp.id + "'";
        SqlDataReader rd = tmp.ExecuteReader(sql);
        return rd;
    }
    public int chauser(users tmp) //验证商品名
    {
        string sql = "select count(*) from T_TABLE where T_ID = '" + tmp.id + "'";
        int result = tmp.ExecuteScalar(sql);
        return result;
    }
    public SqlDataReader getallgong(users tmp)  //查询全部信息
    {
        string sql = "Select G_ID,G_NAME,G_ADDRESS,G_PHONE,G_REN from G_TABLE where G_ID = '" + tmp.id + "'";
        SqlDataReader rd = tmp.ExecuteReader(sql);
        return rd;
    }
    public int chagong(users tmp) //验证商品名
    {
        string sql = "select count(*) from G_TABLE where G_ID = '" + tmp.id + "'";
        int result = tmp.ExecuteScalar(sql);
        return result;
    }
    public SqlDataReader getallyao(users tmp)  //查询全部信息
    {
        string sql = "Select Y_ID,Y_NAME,Y_GUIGE,Y_FUNCTION,Y_PLACE,Y_TYPE,Y_GNAME from Y_TABLE where Y_ID = '" + tmp.id + "'";
        SqlDataReader rd = tmp.ExecuteReader(sql);
        return rd;
    }
    public int chayao(users tmp) //验证商品名
    {
        string sql = "select count(*) from Y_TABLE where Y_ID = '" + tmp.id + "'";
        int result = tmp.ExecuteScalar(sql);
        return result;
    }
    public int kucun(users tmp) //验证商品
    {
        string sql = "select count(*) from K_TABLE where K_ID = '" + tmp.id + "' ";
        int result = tmp.ExecuteScalar(sql);
        return result;
    }
   
    public int insertkucun(users tmp)  //添加商品
    {
        string sql = "Insert into K_TABLE (K_DANHAO,K_TIME,K_ID,K_NAME,K_NUMBER,K_TNAME,K_YOUQI) values('" + tmp.dh + "','" + tmp.time + "','" + tmp.id + "','" + tmp.name + "','" + tmp.number + "','" + tmp.tname + "','" + tmp.youxiaoqi + "')";
        int result = tmp.ExeNnQuery(sql);
        return result;
    }
    public DataSet getyao(users tmp)  //获取过期商品
    {
        string sql = "select * from Y_TABLE where Y_YOUQI <= '"+ tmp.youxiaoqi +"'";
        DataSet ds = tmp.GetDs(sql);
        return ds;
    }
    public DataSet getk(users tmp)  //获取过期商品
    {
        string sql = "select * from K_TABLE where K_YOUQI <= '" + tmp.youxiaoqi + "'";
        DataSet ds = tmp.GetDs(sql);
        return ds;
    }
    public int  getkcg(users tmp)  //获取过期商品
    {
        string sql = "select * from K_TABLE where K_YOUQI <= '" + tmp.youxiaoqi + "'";
        int da = tmp.ExecuteScalar(sql);
        return da;
    }
    public SqlDataReader getkun(users tmp)  //获取商品数量
    {
        string sql = "Select K_NUMBER from K_TABLE where K_ID = '" + tmp.id + "'";
        SqlDataReader rd = tmp.ExecuteReader(sql);
        return rd;
    }
     public SqlDataReader getjin(users tmp)  //获取商品数量
    {
        string sql = "Select J_NUMBER from J_TABLE where J_ID = '" + tmp.id + "'";
        SqlDataReader rd = tmp.ExecuteReader(sql);
        return rd;
    }
    public SqlDataReader getxiao(users tmp)  //获取商品数量
    {
        string sql = "Select X_NUMBER from X_TABLE where X_ID = '" + tmp.id + "'";
        SqlDataReader rd = tmp.ExecuteReader(sql);
        return rd;
    }
    public int chayonghu(users tmp) //验证商品名
    {
        string sql = "select count(*) from H_TABLE where H_NAME= '" + tmp.name + "'";
        int result = tmp.ExecuteScalar(sql);
        return result;
    }
    public SqlDataReader getallyonghu(users tmp)  //查询全部信息
    {
        string sql = "Select H_ID,H_NAME,H_PW,H_ADDRESS,H_PHONE,H_BIRTHDAY from H_TABLE where H_NAME = '" + tmp.name + "'";
        SqlDataReader rd = tmp.ExecuteReader(sql);
        return rd;
    }
    public SqlDataReader getusers(users tmp)  //获取员工密码
    {
        string sql = "Select H_ID from H_TABLE where H_ID = '" + tmp.id+ "'";
        SqlDataReader rd = tmp.ExecuteReader(sql);
        return rd;
    }
    public int denlu(users tmp)  //验证登陆
    {
        string sq = "select count(*) from H_TABLE where H_NAME='" + name + "'and H_PW='" + ps + "'";
        int result = tmp.ExecuteScalar(sq);
        return result;
    }
}